<template>
  <div class="Classification">
    <el-main>
      <div>
        <el-form ref="form" :model="form" label-width="50px">
          <el-row>
            <el-col :span="8">
              <div class="grid-content bg-purple">
                <el-form-item label="公司:">
                  <el-input v-model="form.company" style="width:230px;"></el-input>
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="9">
              <div class="grid-content bg-purple">
                <el-form-item label="部门:" prop="useOrganizationId">
                  <el-select
                    v-model="form.useOrganizationId"
                    placeholder="请选择部门"
                    @change="consolelog"
                    style="width:230px;"
                  >
                    <el-option
                      v-for="item in list"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="3">
              <div class="grid-content bg-purple">
                <el-button type="primary" icon="el-icon-search" @click="search">搜索</el-button>
              </div>
            </el-col>
            <el-col :span="4">
              <div class="grid-content bg-purple-light">
                <el-button
                  type="primary"
                  icon="el-icon-document"
                  @click="ExportAssetReportByType"
                >导出</el-button>
              </div>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <el-table
        ref="multipleTable"
        :data="tableData3"
        border
        stripe
        height="400"
        tooltip-effect="dark"
        style="width: 100%"
        @selection-change="handleSelectionChange"
      >
        <!-- <el-table-column prop="assetTypeId" label="编号" style="width: 16%"></el-table-column> -->
        <el-table-column prop="assetTypeName" label="资产分类" style="width: 16%"></el-table-column>
        <el-table-column prop="using" label="在用" style="width: 16%"></el-table-column>
        <el-table-column prop="idle" label="闲置" style="width: 16%"></el-table-column>
        <el-table-column prop="waste" label="已报废" style="width: 16%"></el-table-column>
        <el-table-column prop="total" label="合计" style="width: 16%"></el-table-column>
      </el-table>
      <br>
     <!--  <div class="block">
        <el-row :gutter="20">
          <el-col :span="4">
            <div class="grid-content bg-purple">
              <!-- <span class="demonstration">已选择0条</span> -->
         <!--    </div>
          </el-col>
          <el-col :span="10">
            <div class="grid-content bg-purple">
              <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="currentPage4"
                :page-sizes="[10, 20, 30, 40]"
                :page-size="10"
                layout="prev, pager, next, sizes, jumper"
                :total="400"
              ></el-pagination>
            </div>
          </el-col>
        </el-row>
      </div> -->
    </el-main>
  </div>
</template>
<script>
import { axiosPost, axiosGet,requestUrl} from "@/api/index.js";
export default {
  data() {
    return {
      form: {
        company: "",
        useOrganizationId: ""
      },
      tableData3: [],
      currentPage1: 5,
      currentPage2: 5,
      currentPage3: 5,
      currentPage4: 1,
      multipleSelection: [],
      list: []
    };
  },
  //获取公司部门接口
  beforeMount() {
    axiosGet("Account/GetOrganizationInfo", null).then(res => {
      if (res.status === 200 && res.data.success) {
        this.list = res.data.data;
      } else {
      }
    });
    axiosGet("Asset/GetAssetReportByType", null).then(res => {
      if (res.status === 200 && res.data.success) {
        this.tableData3 = res.data.data;
      } else {
      }
    });
  },
  methods: {
    toggleSelection(rows) {
      if (rows) {
        rows.forEach(row => {
          this.$refs.multipleTable.toggleRowSelection(row);
        });
      } else {
        this.$refs.multipleTable.clearSelection();
      }
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    handleSizeChange(val) {
      // console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      // console.log(`当前页: ${val}`);
    },
    consolelog() {
      this.useOrganizationId = this.form.useOrganizationId;
    },
    //导出资产分类使用情况接口
    ExportAssetReportByType() {
      var bean = {
        useOrganizationId: this.form.useOrganizationId
      };
      // console.log(this.form.useOrganizationId);

      /* axiosGet("/Asset/ExportAssetReportByType", bean).then(res => {
        if (res.status == 200 && res.data.success) {
        }
      }); */
       window.location.href = requestUrl + "Asset/ExportAssetReportByType";
    },
    //按部门搜索
    search() {
      var bean = {
        useOrganizationId: this.form.useOrganizationId
      };
      axiosGet("/Asset/GetAssetReportByType", bean).then(res => {
        if (res.status === 200 && res.data.success) {
        }
      });
    }
  }
};
</script>
<style lang="scss" scoped>
.Classification {
  height: 100%;
}
</style>
